<!--
 * @Author: yhx 2045399856@qq.com
 * @Date: 2024-04-02 09:16:54
 * @LastEditTime: 2024-04-02 11:48:04
 * @FilePath: \electron-wallpaper\src\renderer\src\components\Navbar.vue
 * @Description: 
 * 
-->
<script setup>
import { Close, Help, Minus, Pic, Pushpin, SettingTwo } from '@icon-park/vue-next'
import { ref } from 'vue'
defineProps({
  title: String
})

async function quit() {
  await window.api.winQuit()
}

function openExternal(url) {
  window.api.openExternal(url)
}

// 最小化
function minimize() {
  window.api.winMinimize()
}

const isToggleTop = ref(false)
// 窗口置顶
function toggleTop() {
  window.api.winToggleTop()
  isToggleTop.value = !isToggleTop.value
}
</script>

<template>
  <div class="nav-bar-box">
    <div class="title">{{ title }}</div>
    <div class="right">
      <div class="no-drag" title="首页" @click="$router.push('/')">
        <pic theme="outline" size="18" :fill="$route.path === '/' ? '#409eff' : '#333'" />
      </div>
      <div
        class="no-drag verticalLine"
        :class="$route.path === '/' ? 'active' : ''"
        title="设置"
        @click="$router.push('/setting')"
      >
        <setting-two
          theme="outline"
          size="18"
          :fill="$route.path === '/setting' ? '#409eff' : '#333'"
        />
      </div>
      <div class="help no-drag" title="帮助中心" @click="$router.push('/help')">
        <help theme="outline" size="18" :fill="$route.path === '/help' ? '#409eff' : '#333'" />
      </div>
      <div class="no-drag" :title="isToggleTop ? '取消置顶' : '置顶'" @click="toggleTop">
        <Pushpin theme="outline" size="18" :fill="isToggleTop ? '#d0021b' : '#333'" />
      </div>
      <div class="no-drag" title="最小化" @click="minimize">
        <minus theme="outline" size="24" fill="#000000" />
      </div>
      <div class="no-drag quit" title="退出程序" @click="quit">
        <close theme="outline" size="18" fill="#d0021b" />
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.nav-bar-box {
  width: 100%;
  display: flex;
  padding: 5px 10px;
  align-items: center;
  justify-content: space-between;
  color: #1f1f1f;
  font-family: '宋体';
  font-size: 14px;

  &:not(div.title) {
    cursor: pointer;
  }

  .title {
  }

  .right {
    justify-content: center;
    align-items: center;
    display: flex;

    div {
      margin: auto;
      display: flex;
      justify-content: center;
      align-items: center;

      &:not(:last-child) {
        padding-right: 6px;
      }

      span {
        display: flex;
      }
    }

    .verticalLine {
      border-right: 2px solid #333;
      margin-right: 5px;
    }
  }
}
</style>
